package cool.webstudy.admin.service.impl;

import cool.webstudy.admin.service.ApiLoggerService;
import cool.webstudy.common.constant.LoggerConstant;
import cool.webstudy.common.model.dto.logger.api.CreateApiLogDBDTO;
import cool.webstudy.common.model.dto.logger.api.CreateApiLogESDTO;
import org.springframework.stereotype.Service;

/**
 * @author 莫振双
 * @date 2024/12/2 11:57
 * @description: 接口日志服务实现类
 */
@Service
public class ApiLoggerServiceImpl extends BaseLoggerServiceImpl implements ApiLoggerService {

    /**
     * 发送接口日志到数据库MQ
     *
     * @param dto 创建接口请求记录日志数据库数据模型
     * @return
     */
    @Override
    public Boolean sendApiLogToDBMQ(CreateApiLogDBDTO dto) {
        sendMessage(dto, LoggerConstant.API_LOG_DB_TOPIC, LoggerConstant.API_LOG_DB_TOPIC_KEY);
        return true;
    }

    /**
     * 发送接口日志到ES MQ
     *
     * @param dto 创建接口请求记录日志保存至ES数据模型
     * @return
     */
    @Override
    public Boolean sendApiLogToESMQ(CreateApiLogESDTO dto) {
        sendMessage(dto, LoggerConstant.API_LOG_ES_TOPIC, LoggerConstant.API_LOG_ES_TOPIC_KEY);
        return true;
    }
}
